package cn.gemiman.daoyi.aihu.jhl;

import cn.gemiman.daoyi.module.system.controller.admin.dict.vo.data.DictDataRespVO;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.List;

@Slf4j
public class AihuJhlSqlGeneratorUtils {
    @SneakyThrows
    public static void main(String[] args) {
        ExcelReader reader = ExcelUtil.getReader("/Users/gemiman/Documents/云享嘉/设备消息类型.xlsx");
        List<DictDataRespVO> all = reader.readAll(DictDataRespVO.class);
        String template = """
                INSERT INTO system_dict_data (sort, label, value, dict_type, status, color_type, css_class, remark,
                                              creator, create_time, updater, update_time, deleted)
                VALUES ({}, '{}', '{}', 'equipment_msg_type', 0, '', '', '', '1', '2024-08-07 23:37:15', '1', '2024-08-07 23:37:15', false);
                """;
        List<String> list = all.stream().map(d -> StrUtil.format(template, d.getSort(), d.getLabel(), d.getValue())).toList();
        FileUtil.writeLines(list, new File("/Users/gemiman/IdeaProjects/daoyicode/daoyi-cloud-pro/daoyi-server/src/test/java/cn/gemiman/daoyi/aihu/jhl/sql/设备消息类型.sql"), StandardCharsets.UTF_8);
    }
}
